//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.kun.portal.webframe.po;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.kun.framework.core.util.DateUtils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(
        name = "fw_role"
)
@DynamicUpdate
@Cacheable
@Cache(
        usage = CacheConcurrencyStrategy.READ_WRITE
)
public class FwRolePo implements Serializable {
    public static final String ROLE_PRIVATE = "1";
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(
            generator = "role_id"
    )
    @GenericGenerator(
            name = "role_id",
            strategy = "uuid"
    )
    @Column(
            name = "role_id",
            length = 32,
            nullable = false
    )
    private String roleId;
    @Column(
            name = "role_code",
            length = 100,
            unique = true
    )
    private String roleCode;
    @Column(
            name = "role_name",
            length = 200
    )
    private String roleName;
    @Column(
            name = "team_id",
            length = 64
    )
    private String teamId;
    @Column(
            name = "team_type",
            length = 64
    )
    private String teamType;
    @Column(
            name = "parent_code",
            length = 100
    )
    private String parentCode;
    @Column(
            name = "parent_name",
            length = 100
    )
    private String parentName;
    @Column(
            name = "creator",
            length = 32
    )
    private String creator;
    @Column(
            name = "role_status",
            length = 5
    )
    private String roleStatus = "1";
    @Column(
            name = "create_time",
            length = 20
    )
    private String createTime;
    @Column(
            name = "modify_time",
            length = 20
    )
    private String modifyTime;
    @Column(
            name = "role_type",
            length = 5
    )
    private String roleType = "0";
    @JsonIgnore
    @ManyToMany(
            cascade = {},
            fetch = FetchType.LAZY
    )
    @JoinTable(
            name = "fw_role_user",
            joinColumns = {@JoinColumn(
                    name = "role_id",
                    referencedColumnName = "role_id"
            )},
            inverseJoinColumns = {@JoinColumn(
                    name = "user_id",
                    referencedColumnName = "user_id"
            )}
    )
    @Cache(
            usage = CacheConcurrencyStrategy.READ_WRITE
    )
    private List<FwUserPo> userList;
//    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
//    @ManyToOne(
//            cascade = {},
//            fetch = FetchType.EAGER
//    )
//    @JoinColumn(
//            name = "team_id",
//            referencedColumnName = "team_id",
//            insertable = false,
//            updatable = false
//    )
//    @Cache(
//            usage = CacheConcurrencyStrategy.READ_WRITE
//    )
//    private FwTeamPo teamPo;
    @Transient
    private List<String> moduleList;

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getRoleId() {
        return this.roleId;
    }

    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }

    public String getTeamId() {
        return this.teamId;
    }

    public void setTeamId(String teamId) {
        this.teamId = teamId;
    }

    public String getTeamType() {
        return this.teamType;
    }

    public void setTeamType(String teamType) {
        this.teamType = teamType;
    }

    public String getRoleCode() {
        return this.roleCode;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleName() {
        return this.roleName;
    }

    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }

    public String getParentCode() {
        return this.parentCode;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getCreator() {
        return this.creator;
    }

    public void setRoleStatus(String roleStatus) {
        this.roleStatus = roleStatus;
    }

    public String getRoleStatus() {
        return this.roleStatus;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getCreateTime() {
        return this.createTime;
    }

    public String getModifyTime() {
        return this.modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    public String getParentName() {
        return this.parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public String getRoleType() {
        return this.roleType;
    }

    public void setRoleType(String roleType) {
        this.roleType = roleType;
    }

    public List<FwUserPo> getUserList() {
        return this.userList;
    }

    public void setUserList(List<FwUserPo> userList) {
        this.userList = userList;
    }

//    public FwTeamPo getTeamPo() {
//        return this.teamPo;
//    }
//
//    public void setTeamPo(FwTeamPo teamPo) {
//        this.teamPo = teamPo;
//    }

    public int hashCode() {
        int result = 1;
        result = 31 * result + (this.roleId == null?0:this.roleId.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if(this == obj) {
            return true;
        } else if(obj == null) {
            return false;
        } else if(this.getClass() != obj.getClass()) {
            return false;
        } else {
            FwRolePo other = (FwRolePo)obj;
            if(this.roleId == null) {
                if(other.roleId != null) {
                    return false;
                }
            } else if(!this.roleId.equals(other.roleId)) {
                return false;
            }

            if(this.roleCode == null) {
                if(other.roleCode != null) {
                    return false;
                }
            } else if(!this.roleCode.equals(other.roleCode)) {
                return false;
            }

            return true;
        }
    }

    public FwRolePo() {
    }

    public FwRolePo(String roleCode, String roleName, String creator) {
        this.roleCode = roleCode;
        this.roleName = roleName;
        this.creator = creator;
        this.createTime = DateUtils.getNowDate();
        this.modifyTime = DateUtils.getNowDate();
    }

    public List<String> getModuleList() {
        return this.moduleList;
    }

    public void setModuleList(List<String> moduleList) {
        this.moduleList = moduleList;
    }

    public void setRoleUserList(List<Object> roleUserList) {
        if(this.userList == null && roleUserList != null) {
            this.userList = new ArrayList();
        }

        Iterator var3 = roleUserList.iterator();

        while(var3.hasNext()) {
            Object o = var3.next();
            Map<String, String> map = (Map)o;
            FwUserPo user = new FwUserPo();
            user.setUserId((String)map.get("userId"));
            this.userList.add(user);
        }

    }
}
